#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 颜色宏定义
#define RESET  "\033[0m"
#define BOLD   "\033[1m"
#define RED    "\033[31m"
#define GREEN  "\033[32m"
#define YELLOW "\033[33m"
#define BLUE   "\033[34m"
#define CYAN   "\033[36m"
#define WHITE  "\033[37m"

//普通用户部分
struct flimation
{
	char flitime[30];          //起飞时间
	char arrtime[50];          //到达时间
	char fliname[40];          //航空公司名字
	char flinum[10];           //航班号
	char fliseat;              //座位号
	char pldture[20];          //始发地
	char destination[20];      //目的地
	struct flimation *next;
	struct flimation *prev;
};

struct userinfo
{
	char user_name[50];        //用户名
	char contact[20];          //联系方式
	char password[30];         //用户密码
	int flag;                  //拉黑标志
};

struct flisyt
{
	struct userinfo user;           //用户信息
	struct flimation fltmation;     //用户的航班信息
	struct flisyt *next;       
	struct flisyt *prev;
};

//双向循环链表的初始化
struct flisyt *fli_init()
{
	//初始化头结点
	struct flisyt *head=malloc(sizeof(struct flisyt));
	head->next=head;
	head->prev=head;
	return head;
}

//定义全局指针，用于存储此时登录的用户所在结点
struct flisyt *overall=NULL;

//普通用户模式
void user(struct flisyt *head)
{
	//定义变量获取用户输入
	char n;
	char user_name[20];
	char user_password[20];
	int found=0;
	//是否被拉黑标记
	int t=0;
	
	//准备链表新结点
	struct flisyt *newuser=malloc(sizeof(struct flisyt));
	newuser->next=NULL;
	newuser->prev=NULL;
	
	//定义指针用于将新结点与链表链接起来
	struct flisyt *p=head;
	while(p->next!=head)
		p=p->next;
	newuser->prev=p;
	p->next=newuser;
	newuser->next=head;
	head->prev=newuser;
	printf(BOLD CYAN"a.用户注册\n"RESET);
	printf(BOLD CYAN"b.用户登录\n"RESET);
	getchar();
	scanf("%c",&n);
	switch(n)
	{
		case 'a':
		{
fl:
			p=head;
			printf(BOLD YELLOW"请输入您的用户名：\n"RESET);
			scanf("%s",newuser->user.user_name);
			while(p->next!=newuser)
			{
				p=p->next;
				if(strcmp(newuser->user.user_name,p->user.user_name)==0)
				{
					printf(BOLD YELLOW"用户名重复，请重新输入喵！\n"RESET);
					goto fl;
				}
			}
			printf(BOLD YELLOW"请输入您的联系方式：\n"RESET);
			scanf("%s",newuser->user.contact);
			printf(BOLD YELLOW"请输入新密码：\n"RESET);
			scanf("%s",newuser->user.password);
			printf(BOLD YELLOW"注册中···\n"RESET);
			printf(BOLD YELLOW"注册成功喵！\n"RESET);
			printf(BOLD YELLOW"欢迎新用户喵！\n"RESET);
			newuser->user.flag=0;
		}
		case 'b':
		{
fl4:
			found=0;
			printf(BOLD CYAN"a.登录您的账号\n"RESET);
			printf(BOLD CYAN"q.退出程序\n"RESET);
			getchar();
			scanf("%c",&n);
			if(n=='q')
				exit(0);
			printf(BOLD YELLOW"用户名："RESET);
			scanf("%s",user_name);
			printf(BOLD YELLOW"密码："RESET);
			scanf("%s",user_password);
			struct flisyt *q=head->next;
			while(q!=head)
			{
				if(strcmp(user_name,q->user.user_name)==0&&strcmp(user_password,q->user.password)==0)
				{
					if(q->user.flag==1)
					{
						printf(BOLD RED"您已被管理员拉黑，登录失败！\n"RESET);
						found=1;
						t=1;
						goto fl4;
					}
					else
					{
						printf(BOLD YELLOW"登录成功！欢迎尊敬的%s桑麻！\n"RESET,q->user.user_name);
						//记录当前登录的用户结点
						overall=q;
						t=0;
						found=1;
						break;
					}
				}
				q=q->next;
			}
			if(!found)
			{
				printf(BOLD YELLOW"登录失败喵！请重新登录！\n"RESET);
				t=1;
				goto fl4;
			}
			break;
		}
	}
	if(t==0)
	{
		printf(BOLD YELLOW"尊敬的%s桑麻，请选择您要使用的服务喵！\n"RESET,newuser->user.user_name);
	}
}

//普通用户买票
void buyfli(struct flimation *head2,struct flisyt *head)
{
	int t=0;
	//定义一个指针得到此时正在买票的用户数据
	struct flisyt *p=overall;
	//定义一个指针获取航班信息
	struct flimation *q=head2;
	//定义一个指针获取已被购买座位信息
	struct flisyt *seat=head;
fl8:
	//展示已有航班信息
	while(q->next!=head2)
	{
		q=q->next;
		printf(BOLD YELLOW"===航班信息===\n"RESET);
		printf(BOLD CYAN"航空公司：%s\n"RESET,q->fliname);
		printf(BOLD CYAN"始发地：%s\n"RESET,q->pldture);
		printf(BOLD CYAN"目的地：%s\n"RESET,q->destination);
		printf(BOLD CYAN"航班号：%s\n"RESET,q->flinum);
		printf(BOLD CYAN"起飞时间：%s\n"RESET,q->flitime);
		printf(BOLD CYAN"到达时间：%s\n"RESET,q->arrtime);
	}
	//用户输入信息存入对应用户结点中
	printf(BOLD YELLOW"请输入您想要选择的航空公司喵！\n"RESET);
	scanf("%s",p->fltmation.fliname);
	getchar();
	printf(BOLD YELLOW"请输入航班号喵！\n"RESET);
	scanf("%s",p->fltmation.flinum);
	printf(BOLD YELLOW"请输入想要登机的时间喵！\n"RESET);
	scanf("%s",p->fltmation.flitime);
	getchar();
	q=head2;
	while(q->next!=head2)
	{
		q=q->next;
		if(strcmp(p->fltmation.flitime,q->flitime)==0)
		{
			strcpy(p->fltmation.arrtime,q->arrtime);
			strcpy(p->fltmation.pldture,q->pldture);
			strcpy(p->fltmation.destination,q->destination);
		}
	}
fl5:
	seat=head;
	printf(BOLD YELLOW"请选择座位喵!(a-z)\n"RESET);
	scanf("%c",&p->fltmation.fliseat);
	while(seat->next!=head)
	{
		seat=seat->next;
		if(seat==p)
			continue;
		if(seat->fltmation.fliseat==p->fltmation.fliseat&&strcmp(seat->fltmation.flitime,p->fltmation.flitime)==0&&strcmp(seat->fltmation.fliname,p->fltmation.fliname)==0&&strcmp(seat->fltmation.flinum,p->fltmation.flinum)==0)
		{
			printf(BOLD YELLOW"非常抱歉喵！该座位已被购买，请重新选择座位喵！QwQ\n"RESET);
			getchar();
			goto fl5;
			break;
		}
	}
	q=head2;
	while(q->next!=head2)
	{
		q=q->next;
		if(strcmp(q->flitime,p->fltmation.flitime)==0&&strcmp(q->fliname,p->fltmation.fliname)==0&&strcmp(q->flinum,p->fltmation.flinum)==0)
			t=1;
	}
	if(t==0)
	{
		printf(BOLD YELLOW"没有本次航班的票！请重新购买喵！\n"RESET);
		goto fl8;
	}
	printf(BOLD YELLOW"请支付\n"RESET);
	printf(BOLD YELLOW"支付中···\n"RESET);
	printf(BOLD YELLOW"购票成功喵！\n"RESET);
}

//普通用户查询航班信息
void searchfli()
{
	struct flisyt *p=overall;
	printf(BOLD YELLOW"===========\n"RESET);
	printf(BOLD CYAN"用户：%s\n"RESET,p->user.user_name);
	printf(BOLD YELLOW"===航班信息===\n"RESET);
	printf(BOLD CYAN"航空公司：%s\n"RESET,p->fltmation.fliname);
	printf(BOLD CYAN"始发地：%s\n"RESET,p->fltmation.pldture);
	printf(BOLD CYAN"目的地：%s\n"RESET,p->fltmation.destination);
	printf(BOLD CYAN"航班号：%s\n"RESET,p->fltmation.flinum);
	printf(BOLD CYAN"座位号：%c\n"RESET,p->fltmation.fliseat);
	printf(BOLD CYAN"起飞时间：%s\n"RESET,p->fltmation.flitime);
	printf(BOLD CYAN"到达时间：%s\n"RESET,p->fltmation.arrtime);
	if(strcmp(p->fltmation.fliname,"神鹰航空")==0)
		printf(BOLD RED"装b我让你飞起来！\n"RESET);
	if(strcmp(p->fltmation.fliname,"曼巴航空")==0)
		printf(BOLD GREEN"孩子们，我回来了！我好想你们！\n"RESET);
	printf(BOLD YELLOW"===========\n"RESET);
}

//普通用户退票
void delfli()
{
	struct flisyt *p=overall;
	strcpy(p->fltmation.flitime,"\t");
	strcpy(p->fltmation.fliname,"\t");
	strcpy(p->fltmation.arrtime,"\t");
	p->fltmation.fliseat='\t';
	strcpy(p->fltmation.flinum,"\t");
	printf(BOLD YELLOW"退票中···\n"RESET);
	printf(BOLD YELLOW"退票成功了喵！\n"RESET);
}

//普通用户改签
void changefli(struct flimation *head2,struct flisyt *head)
{
	char a[20];
	int t=0;
	struct flisyt *p=overall;
	//定义一个指针获取航班信息
	struct flimation *q=head2;
	//定义一个指针获取已被购买座位信息
	struct flisyt *seat=head;
fl9:
	q=head2;
	while(q->next!=head2)
	{
		q=q->next;
		printf(BOLD YELLOW"===航班信息：===\n"RESET);
		printf(BOLD CYAN"航空公司：%s\n"RESET,q->fliname);
		printf(BOLD CYAN"始发地：%s\n"RESET,q->pldture);
		printf(BOLD CYAN"目的地：%s\n"RESET,q->destination);
		printf(BOLD CYAN"航班号：%s\n"RESET,q->flinum);
		printf(BOLD CYAN"起飞时间：%s\n"RESET,q->flitime);
		printf(BOLD CYAN"到达时间：%s\n"RESET,q->arrtime);
	}
	while(1)
	{
		printf(BOLD YELLOW"请输入您要改签的内容喵！\n"RESET);
		printf(BOLD YELLOW"改签完成请按q喵！\n"RESET);
		scanf("%s",a);
		if(strcmp(a,p->fltmation.flitime)==0)
		{
			printf(BOLD YELLOW"请修改登机时间喵！\n"RESET);
			scanf("%s",p->fltmation.flitime);
			printf(BOLD YELLOW"请修改座位号喵！\n"RESET);
			getchar();
			scanf("%c",&p->fltmation.fliseat);
		}
		if(strcmp(a,p->fltmation.fliname)==0)
		{
			printf(BOLD YELLOW"请修改航空公司喵！\n"RESET);
			scanf("%s",p->fltmation.fliname);
			printf(BOLD YELLOW"请修改座位号喵！\n"RESET);
			getchar();
			scanf("%c",&p->fltmation.fliseat);
		}
		if(strcmp(a,p->fltmation.flinum)==0)
		{
			printf(BOLD YELLOW"请修改航班号喵！\n"RESET);
			scanf("%s",p->fltmation.flinum);
fl10:
			printf(BOLD YELLOW"请修改座位号喵！\n"RESET);
			getchar();
			scanf("%c",&p->fltmation.fliseat);
		}
		seat=head;
		while(seat->next!=head)
		{
			seat=seat->next;
			if(seat==p)
				continue;
			if(seat->fltmation.fliseat==p->fltmation.fliseat&&strcmp(seat->fltmation.flitime,p->fltmation.flitime)==0&&strcmp(seat->fltmation.fliname,p->fltmation.fliname)==0&&strcmp(seat->fltmation.flinum,p->fltmation.flinum)==0)
			{
				printf(BOLD YELLOW"非常抱歉喵！该座位已被购买，请重新选择座位喵！QwQ\n"RESET);
				getchar();
				goto fl10;
				break;
			}
		}
		if(a[0]=='q'&&a[1]=='\0')
			break;
	}
	q=head2;
	while(q->next!=head2)
	{
		q=q->next;
		if(strcmp(q->fliname,p->fltmation.fliname)==0&&strcmp(q->flitime,p->fltmation.flitime)==0&&strcmp(q->fliname,p->fltmation.fliname)==0&&strcmp(q->flinum,p->fltmation.flinum)==0)
			t=1;
	}
	if(t==0)
	{
		printf(BOLD YELLOW"没有本次航班的票！请重新选择喵！\n"RESET);
		goto fl9;
	}
	printf(BOLD YELLOW"修改中···\n"RESET);
	printf(BOLD YELLOW"修改成功喵！\n"RESET);
	q=head2;
	while(q->next!=head2)
	{
		q=q->next;
		if(strcmp(p->fltmation.flitime,q->flitime)==0)
		{
			strcpy(p->fltmation.arrtime,q->arrtime);
			strcpy(p->fltmation.pldture,q->pldture);
			strcpy(p->fltmation.destination,q->destination);
		}
	}
}

//退出程序时销毁链表
void broke_list(struct flisyt *head)                        
{
	struct flisyt *p=head->next;                            //定义一个指针指向头结点
	struct flisyt *next=NULL;                               //再定义一个指针暂时指向空
	while(p!=head)                                              //如果当前结点不为空
	{
		next=p->next;                                           //next指针指向下一个结点
		free(p);                                                //释放当前结点
		p=next;	                                                //将p指针移向下一个结点
	}
	free(head);
}

//管理员登录
void adminin()
{
	//定义数组存放登录时输入的密码
	char adpassword[30];
fl7:
	printf(BOLD YELLOW"请输入管理员密码：\n"RESET);
	scanf("%s",adpassword);
	if(strcmp(adpassword,"admin123")==0)
	{
		printf(BOLD YELLOW"登录成功喵！欢迎尊敬的管理员monster！\n"RESET);
	}
	else
	{
		printf(BOLD YELLOW"登录失败喵！请重新登录！\n"RESET);
		goto fl7;
	}
}

//管理员拉入黑名单
void addblacklist(struct flisyt *head)
{
	//定义数组获取管理员拉黑的用户名
	char adminname[30];
	//是否拉黑成功标记
	int t=0;
	struct flisyt *p=head;
	printf(BOLD YELLOW"===========\n"RESET);
	while(p->next!=head)
	{
		p=p->next;
		printf(BOLD CYAN"用户：%s\n",p->user.user_name);
		printf(BOLD CYAN"联系方式：%s\n",p->user.contact);
		printf(BOLD YELLOW"===========\n"RESET);
	}
	printf(BOLD YELLOW"monster！以上是用户名单，您想要拉黑哪个用户喵？\n"RESET);
	scanf("%s",adminname);
	p=head;
	while(p->next!=head)
	{
		p=p->next;
		if(strcmp(p->user.user_name,adminname)==0)
		{
			p->user.flag=1;
			printf(BOLD YELLOW"拉黑中···\n"RESET);
			printf(BOLD YELLOW"拉黑成功喵！\n"RESET);
			t=1;
			break;
		}
	}
	if(t==0)
		printf(BOLD YELLOW"monster!没有您想拉黑的用户喵！\n"RESET);
}

//管理员解除黑名单
void reblacklist(struct flisyt *head)
{
	//定义数组获取管理员解除拉黑的用户名
	char adminname[30];
	//是否解除拉黑成功标记
	int t=0;
	struct flisyt *p=head;
	printf(BOLD YELLOW"===========\n"RESET);
	while(p->next!=head)
	{
		p=p->next;
		if(p->user.flag==1)
		{
			printf(BOLD RED"用户：%s\n"RESET,p->user.user_name);
			printf(BOLD RED"联系方式：%s\n"RESET,p->user.contact);
			printf(BOLD YELLOW"===========\n"RESET);
		}
	}
	printf(BOLD YELLOW"monster!以上是已被拉黑的用户，请选择要解除拉黑的用户喵！\n"RESET);
	scanf("%s",adminname);
	p=head;
	while(p->next!=head)
	{
		p=p->next;
		if(strcmp(p->user.user_name,adminname)==0)
		{
			p->user.flag=0;
			printf(BOLD YELLOW"解除拉黑中···\n"RESET);
			printf(BOLD YELLOW"解除拉黑成功喵！\n"RESET);
			t=1;
			break;
		}
	}
	if(t==0)
		printf(BOLD YELLOW"monster!没有您想解除拉黑的用户喵！\n"RESET);
}

//管理员修改用户的航班信息
void changemation(struct flisyt *head)
{
	//定义数组存储管理员要修改的用户名
	char changename[30];
	char change1[30],change2[30];
	int t=0;
	struct flisyt *p=head;
	printf(BOLD YELLOW"************\n"RESET);
	while(p->next!=head)
	{
		p=p->next;
		printf(BOLD CYAN"用户：%s\n"RESET,p->user.user_name);
		printf(BOLD YELLOW"===航班信息===\n"RESET);
		printf(BOLD CYAN"航空公司：%s\n"RESET,p->fltmation.fliname);
		printf(BOLD CYAN"始发地：%s\n"RESET,p->fltmation.pldture);
		printf(BOLD CYAN"目的地：%s\n"RESET,p->fltmation.destination);
		printf(BOLD CYAN"航班号：%s\n"RESET,p->fltmation.flinum);
		printf(BOLD CYAN"座位号：%c\n"RESET,p->fltmation.fliseat);
		printf(BOLD CYAN"起飞时间：%s\n"RESET,p->fltmation.flitime);
		printf(BOLD CYAN"到达时间：%s\n"RESET,p->fltmation.arrtime);
		printf(BOLD YELLOW"************\n"RESET);
	}
	printf(BOLD YELLOW"monster！以上是目前用户的航班信息，请选择要修改的用户喵！\n"RESET);
	scanf("%s",changename);
	p=head;
	while(p->next!=head)
	{
		p=p->next;
		if(strcmp(changename,p->user.user_name)==0)
		{
			printf(BOLD YELLOW"************\n"RESET);
			printf(BOLD CYAN"用户：%s\n"RESET,p->user.user_name);
			printf(BOLD YELLOW"===航班信息===\n"RESET);
			printf(BOLD CYAN"航空公司：%s\n"RESET,p->fltmation.fliname);
			printf(BOLD CYAN"始发地：%s\n"RESET,p->fltmation.pldture);
			printf(BOLD CYAN"目的地：%s\n"RESET,p->fltmation.destination);
			printf(BOLD CYAN"航班号：%s\n"RESET,p->fltmation.flinum);
			printf(BOLD CYAN"座位号：%c\n"RESET,p->fltmation.fliseat);
			printf(BOLD CYAN"起飞时间：%s\n"RESET,p->fltmation.flitime);
			printf(BOLD CYAN"到达时间：%s\n"RESET,p->fltmation.arrtime);
			printf(BOLD YELLOW"************\n"RESET);
			printf(BOLD YELLOW"请输入您要修改的内容喵！\n"RESET);
			scanf("%s",change1);
			printf(BOLD YELLOW"请输入修改后的内容喵！\n"RESET);
			scanf("%s",change2);
			if(strcmp(change1,p->fltmation.fliname)==0)
				strcpy(p->fltmation.fliname,change2);
			if(strcmp(change1,p->fltmation.flinum)==0)
				strcpy(p->fltmation.flinum,change2);
			if(change1[0]==p->fltmation.fliseat)
				p->fltmation.fliseat=change2[0];
			if(strcmp(change1,p->fltmation.flitime)==0)
				strcpy(p->fltmation.flitime,change2);
			if(strcmp(change1,p->fltmation.pldture)==0)
				strcpy(p->fltmation.pldture,change2);
			if(strcmp(change1,p->fltmation.destination)==0)
				strcpy(p->fltmation.destination,change2);
			printf(BOLD YELLOW"修改中···\n"RESET);
			printf(BOLD YELLOW"修改成功喵！\n"RESET);
			t=1;
			break;
		}
	}
	if(t==0)
		printf(BOLD YELLOW"没有您想要修改的用户喵！\n"RESET);
}

//航班信息链表初始化
struct flimation *fin_init()
{
	struct flimation *head2=malloc(sizeof(struct flimation));
	head2->next=head2;
	head2->prev=head2;
	return head2;
}

//退出程序时销毁航班信息链表
void broke_list2(struct flimation *head2)                        
{
	struct flimation *p=head2->next;                            //定义一个指针指向头结点
	struct flimation *next=NULL;                               //再定义一个指针暂时指向空
	while(p!=head2)                                              //如果当前结点不为空
	{
		next=p->next;                                           //next指针指向下一个结点
		free(p);                                                //释放当前结点
		p=next;	                                                //将p指针移向下一个结点
	}
	free(head2);
}

//添加初始航班1
void addfliinit(struct flimation *head2)
{
	struct flimation *p=head2;
	//准备链表新结点
	struct flimation *newnode=malloc(sizeof(struct flimation));
	newnode->next=NULL;
	newnode->prev=NULL;
	//找到链表尾部并链接
	while(p->next!=head2)
		p=p->next;
	newnode->prev=p;
	p->next=newnode;
	newnode->next=head2;
	head2->prev=newnode;
	strcpy(newnode->fliname,"神鹰航空");
	strcpy(newnode->pldture,"地球");
	strcpy(newnode->destination,"太空");
	strcpy(newnode->flinum,"黑手号");
	strcpy(newnode->flitime,"随时可以起飞！");
	strcpy(newnode->arrtime,"一秒即达！");
}

//添加初始航班2
void addfliinit2(struct flimation *head2)
{
	struct flimation *p=head2;
	//准备链表新结点
	struct flimation *newnode=malloc(sizeof(struct flimation));
	newnode->next=NULL;
	newnode->prev=NULL;
	//找到链表尾部并链接
	while(p->next!=head2)
		p=p->next;
	newnode->prev=p;
	p->next=newnode;
	newnode->next=head2;
	head2->prev=newnode;
	strcpy(newnode->fliname,"曼巴航空");
	strcpy(newnode->pldture,"洛杉矶");
	strcpy(newnode->destination,"某地");
	strcpy(newnode->flinum,"牢大号");
	strcpy(newnode->flitime,"What_can_I_say?");
	strcpy(newnode->arrtime,"Mambaout！");
}

//管理员添加航班信息
void addflimation(struct flimation *head2)
{
	struct flimation *p=head2;
	//准备链表新结点
	struct flimation *newnode=malloc(sizeof(struct flimation));
	newnode->next=NULL;
	newnode->prev=NULL;
	//找到链表尾部并链接
	while(p->next!=head2)
		p=p->next;
	newnode->prev=p;
	p->next=newnode;
	newnode->next=head2;
	head2->prev=newnode;
	//管理员输入新的航班信息
	printf(BOLD YELLOW"monster!请输入新的航班信息喵！\n"RESET);
	printf(BOLD CYAN"航空公司："RESET);
	scanf("%s",newnode->fliname);
	printf(BOLD CYAN"始发地："RESET);
	scanf("%s",newnode->pldture);
	printf(BOLD CYAN"目的地："RESET);
	scanf("%s",newnode->destination);
	printf(BOLD CYAN"航班号："RESET);
	scanf("%s",newnode->flinum);
	printf(BOLD CYAN"起飞时间："RESET);
	scanf("%s",newnode->flitime);
	printf(BOLD CYAN"到达时间："RESET);
	scanf("%s",newnode->arrtime);
	printf(BOLD YELLOW"添加信息中···\n"RESET);
	printf(BOLD YELLOW"添加成功喵！\n"RESET);
}

//管理员模式展示航班信息
void show_flimation(struct flimation *head2)
{
	struct flimation *p=head2;
	printf(BOLD YELLOW"monster!航班信息如下喵！\n"RESET);
	while(p->next!=head2)
	{
		p=p->next;
		printf(BOLD YELLOW"===航班信息===\n"RESET);
		printf(BOLD CYAN"航空公司：%s\n"RESET,p->fliname);
		printf(BOLD CYAN"始发地：%s\n"RESET,p->pldture);
		printf(BOLD CYAN"目的地：%s\n"RESET,p->destination);
		printf(BOLD CYAN"航班号：%s\n"RESET,p->flinum);
		printf(BOLD CYAN"起飞时间：%s\n"RESET,p->flitime);
		printf(BOLD CYAN"到达时间：%s\n"RESET,p->arrtime);
	}
}

int main()
{
	//存储用户选择的选项
	char n1,n2;
	//初始化头结点
	struct flisyt *head=fli_init();               //用户部分信息头结点
	struct flimation *head2=fin_init();           //航班信息头结点
	//插入初始航班
	addfliinit(head2);
	addfliinit2(head2);
	//航班管理系统ui
	while(n1!='q'&&n2!='q')
	{
fl6:
		printf(BOLD YELLOW"===欢迎使用小喵航班管理系统===\n"RESET);
		printf(BOLD CYAN"请选择模式：\n"RESET);
		printf(BOLD CYAN"a.普通用户模式\n"RESET);
		printf(BOLD CYAN"b.管理员模式\n"RESET);
		printf(BOLD CYAN"q.退出系统\n"RESET);
		scanf("%c",&n1);
		switch(n1)
		{
			case 'a':
			{
				user(head);
				getchar();
fl3:
				printf(BOLD CYAN"a.买票\n"RESET);
				printf(BOLD CYAN"b.退票\n"RESET);
				printf(BOLD CYAN"c.改签\n"RESET);
				printf(BOLD CYAN"d.查询航班信息\n"RESET);
				printf(BOLD CYAN"i.退出登录\n"RESET);
				printf(BOLD CYAN"q.退出系统\n"RESET);
				scanf("%c",&n2);
				switch(n2)
				{
					case 'a':
					{
						buyfli(head2,head);
						getchar();
						goto fl3;
						break;
					}
					case 'b':
					{
						delfli();
						getchar();
						goto fl3;
						break;
					}
					case 'c':
					{
						changefli(head2,head);
						getchar();
						goto fl3;
						break;
					}
					case 'd':
					{
						searchfli();
						getchar();
						goto fl3;
						break;
					}
					case 'i':
					{
						getchar();
						goto fl6;
						break;
					}
				}
				break;
			}
			case 'b':
			{
				adminin();
				getchar();
fl2:
				printf(BOLD YELLOW"请选择要使用的功能喵！\n"RESET);
				printf(BOLD RED"a.拉入黑名单\n"RESET);
				printf(BOLD CYAN"b.解除黑名单\n"RESET);
				printf(BOLD CYAN"c.修改航班信息\n"RESET);
				printf(BOLD CYAN"d.添加航班信息\n"RESET);
				printf(BOLD CYAN"e.展示航班信息\n"RESET);
				printf(BOLD CYAN"i.退出登录\n"RESET);
				printf(BOLD CYAN"q.退出系统\n"RESET);
				scanf("%c",&n2);
				switch(n2)
				{
					case 'a':
					{
						addblacklist(head);
						getchar();
						goto fl2;
						break;
					}
					case 'b':
					{
						reblacklist(head);
						getchar();
						goto fl2;
						break;
					}
					case 'c':
					{
						changemation(head);
						getchar();
						goto fl2;
						break;
					}
					case 'd':
					{
						addflimation(head2);
						getchar();
						goto fl2;
						break;
					}
					case 'e':
					{
						show_flimation(head2);
						getchar();
						goto fl2;
						break;
					}
					case 'i':
					{
						getchar();
						goto fl6;
						break;
					}
				}
				break;
			}
		}
	}
	broke_list(head);
	broke_list2(head2);
}